#ifndef _SHA1_H_
#define _SHA1_H_

#include "netfwd.h"

#pragma once

#undef BIG_ENDIAN_HOST

/****************
 * Rotate a 32 bit integer by n bytes
 ****************/
#if defined(__GNUC__) && defined(__i386__)
static inline uint32_t rol( uint32_t x, int n)
{
	__asm__("roll %%cl,%0"
            :"=r" (x)
            :"0" (x),"c" (n));
	return x;
}
#else
#define rol(x,n) ( ((x) << (n)) | ((x) >> (32-(n))) )
#endif


typedef struct {
    uint32_t  h0,h1,h2,h3,h4;
    uint32_t  nblocks;
    unsigned char buf[64];
    int  count;
} SHA1_CONTEXT;


#ifdef __cplusplus
extern "C" {
#endif

void sha1_init( SHA1_CONTEXT * hd );
void sha1_write( SHA1_CONTEXT *hd, unsigned char * buf, uint32_t len );
void sha1_final( SHA1_CONTEXT *hd );

#ifdef __cplusplus
}
#endif

#endif // _SHA1_H_

